NAME = biolabs
SVGIMAGES := $(wildcard *.svg)
EPSIMAGES := $(SVGIMAGES:.svg=.eps)

all: pdf ps
	echo ${EPSIMAGES}

pdf: ${NAME}.pdf

ps: ${NAME}.ps

dvi: ${NAME}.dvi

${NAME}.pdf: ${NAME}.dvi ${EPSIMAGES}
	dvipdfm ${NAME}.dvi

${NAME}.ps: ${NAME}.dvi ${EPSIMAGES}
	dvips ${NAME}.dvi

${NAME}.dvi: ${NAME}.tex ${EPSIMAGES}
	latex ${NAME}.tex
	latex ${NAME}.tex

%.eps: %.svg
	which inkscape || ( \
		echo "Inkscape is not installed or is not the the PATH." && \
		echo "Please, install Inkscape to convert SVG images to EPS." && \
		false \
	)
	inkscape -E $@ $<

clean:
	rm -f \
		${NAME}.aux \
		${NAME}.log \
		${NAME}.dvi \
		${NAME}.ps \
		${NAME}.pdf \
		${EPSIMAGES}
